package com.yanshaohui.repository;

import com.yanshaohui.bean.Person;
import org.springframework.context.annotation.Primary;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * Created by TS-Ysh on 2018-05-14.
 */
@Repository
@Primary
public interface PersonRepository extends ReactiveMongoRepository<Person, Long> {

    //参数是否用Reactive类型好像都可以
    Flux<Person> findByName(Mono<String> lastname);

    @Query("{ 'sex': ?0, 'age': ?1}")
    Flux<Person> findBySexAndAge(Integer sex, Integer age);
}
